<template>
	<view style="width: 100% !important;">
		<view class="nav">
			<view class="nav-left">
				<scroll-view scroll-y :style="'height:'+height+'px'">
					<view class="nav-left-item" v-for="(item,index) in categoryList"
						@click="categoryClickMain(item,index)" :key="index"
						:style="index==categoryActive?'color:'+activeTextColor+';background-color:'+activeBackgroundColor:''">
						<view v-if="index==categoryActive"
							style="width: 10upx;height: 100%;background-color: #CF2F2D;position: relative;left: -25upx;border-radius: 0 20upx 20upx 0;"
							class="">
						</view>
						<view style="width: 130upx;" class="zz">{{item[label]}}</view>
					</view>
				</scroll-view>
			</view> 
			<view class="nav-right">
				<scroll-view scroll-y :scroll-top="scrollTop" @scroll="scroll" :style="'height:'+height+'px'"
					scroll-with-animation>
					<view class="nav-right-item" v-for="(item,index2) in subCategoryList" :key="index2"
						>
						<view class="itemViewTitle">
							{{ item.name }}
						</view> 
						<view v-for="(infoItem,infoIndex) of item.stationResultList"  class="">
							<view class="itemView">
								<view class="itemViewLeft">
									<image v-if="!infoItem.dbUserLogo" src="./inavatar.png" mode=""></image>
									<image v-else :src="inUrl + '/file/download/preview/0?path=' + infoItem.dbUserLogo.replace(/\\/g, '/')" mode=""></image>
								</view>
								<view class="itemViewRight">
									<view class="itemViewRightTop">
										<view class="itemViewRightTopLeft" style="padding-bottom: 20rpx;">
											{{infoItem.dbUserName}}
										</view>
										<view class="itemViewRightTopRight">
											<text class="itemViewRightTopRightText" @tap="revice(infoItem,infoIndex)">
												提报问题
											</text>
										</view>
									</view>
									<!-- <view class="itemViewRightCenter">
										{{infoItem.staName}}
									</view> -->
									<view class="itemViewRightBottom">
										{{infoItem.dbUserPosition}}
									</view>
								</view>
							</view>
						</view>
						
						
					
					</view>
				</scroll-view>
			</view>
		</view>
	</view>
</template>

<script>
	import * as config from '@/config/index.js';
	export default {
		name: "category",
		data() {
			return {
				inUrl: config.def().baseUrl,
				height: 0,
				scrollTop: 0,
				scrollHeight: 0,
				categoryActive: 0,
				activeStyle: {
					color: this.activeTextColor,
					backgroundColor: this.activeBackgroundColor
				}
			}
		},
		props: {
			//主分类激活索引
			defaultActive: {
				type: Number,
				default: 0
			},
			//主分类List
			categoryList: {
				type: Array,
				default: () => {
					return null;
				}
			},
			//侧边分类List
			subCategoryList: {
				type: Array,
				default: () => {
					return null;
				}
			},
			activeTextColor: {
				type: String,
				default: '#F24544'
			},
			activeBackgroundColor: {
				type: String,
				default: '#e5e5e5'
			},
			label: {
				type: String,
				default: 'name' 
			},
			imgSrc: {
				type: String,
				default: 'logo'
			},
			//主分类点击事件
			categoryMainClick: {},
			//子分类点击事件
			categorySubClick: {}
		},
		methods: {
			revice(e,v){
				this.$emit('tjly',e,v)
			},
			scroll(e) {
				this.scrollHeight = e.detail.scrollHeight;
			},
			categoryClickMain(category, index) {
				this.$emit('categoryMainClick', category, index)
				this.categoryActive = index;
				this.scrollTop = -this.scrollHeight * index;
			},
			categoryClickSub(category) {
				this.$emit('categorySubClick', category)
			}
		},
		mounted() {
			this.categoryActive = this.defaultActive
			uni.getSystemInfo({
				success: res => {
					this.height = res.screenHeight - 116;
				}
			})
		},
		watch: {
			subCategoryList(newValue, oldValue) {

			}
		},
	}
</script>

<style scoped lang="less">
	.nav {
		display: flex;
		width: 100%;
	}

	.nav-left {
		width: 25%;
	}

	.nav-left-item {
		height: 50px;
		/* border-right: solid 1px #E0E0E0;
		border-bottom: solid 1px #E0E0E0; */
		background-color: #F7F8FA;
		font-size: 16px;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.nav-right {
		width: 70%;
		padding-top: 11px;
	}

	.nav-right-item {
		width: 100%;
		
		float: left;
		// text-align: center;
		padding: 20upx 40upx;
		font-size: 13px;
		// display: flex;
		// align-items: center;
	}

	.nav-right-item image {
		width: 140upx;
		height: 200upx;
	}

	.active {
		color: #CF2F2D;
	}

	.padding {
		height: var(--status-bar-height);
		width: 100%;
		top: 0;
		position: fixed;
		background-color: #F24544;
	}

	.itemView {
		display: flex;
		align-items: center;

		width: 95%;
		height: 280upx;
		

		
	}
	
	.zz{
		font-size: 15px !important;
		// overflow: hidden;
		// white-space: nowrap;
		// text-overflow: ellipsis;
		// -o-text-overflow: ellipsis;
		
		word-break: break-all;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		/* 这里是超出几行省略 */
		overflow: hidden;
	}
	
	.itemViewTitle{
		font-size: 30upx;
		padding: 20upx 0;
		color: #333333;
		text-align: left !important;
	}
	
	
	.itemViewLeft {}
	
	.itemViewRight {
		width: 100%;
		padding-left: 20upx;
	
		.itemViewRightTop {
			display: flex;
			align-items: center;
			padding: 20upx 0 10upx 0;
			width: 100%;
	
			.itemViewRightTopLeft {
				flex: 3;
				text-align: left;
				color: #000000;
				font-size: 17px;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
				-o-text-overflow: ellipsis;
			}
	
			.itemViewRightTopRight {
				flex: 3;
				text-align: right;
				position: relative;
				left: 50upx;
				.itemViewRightTopRightText {
					text-align: center;
					color: #FFFFFF;
					background-color: #D3312F;
					font-size: 11px;
					padding: 10upx 20upx;
					border-radius: 24upx;
				}
			}
		}
	
		.itemViewRightCenter {
			padding: 5upx 0;
			text-align: left;
			color: #999999;
			font-size: 13px;
			word-break: break-all;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 2;
			/* 这里是超出几行省略 */
			overflow: hidden;
		}
	
		.itemViewRightBottom {
			padding: 5upx 0;
			text-align: left;
			color: #999999;
			font-size: 13px;
			word-break: break-all;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 2;
			/* 这里是超出几行省略 */
			overflow: hidden;
		}
	}
</style>
